
----精彩活动界面

--#include "data\config\activity\ActivityGuideCfg.lua" once

--[[
活动引导面板的传送
]]
function ActivityGuideTeleport( sysarg, activityId )
	--print("ActivityGuideTeleport, activityId="..activityId)
	local guideCfg = GetActivityGuideCfgById( activityId )
	if guideCfg and guideCfg.teleId then
		CommonTeleportByTeleId( sysarg, guideCfg.teleId )
	end
end


function GetActivityGuideCfgById( activityId )
	for groupIdx, guideGroupCfg in ipairs( ActivityGuideCfg ) do
		for i, guildCfg in ipairs( guideGroupCfg.activities ) do
			if guildCfg.id == activityId then
				return guildCfg
			end
		end
	end
	return nil
end


function SendActivityGuideTimes( sysarg )
	local netPack = DataPack.allocPacket(sysarg, enDefaultEntitySystemID, sSendActivityGuideTimes)
	--local netPack = DataPack.allocPacket(sysarg, 0, 85)
	if netPack then
		local count = GetActivityGuideCount()
		DataPack.writeShort(netPack, count)
		for groupIdx, guideGroupCfg in ipairs( ActivityGuideCfg ) do
			for i, guildCfg in ipairs( guideGroupCfg.activities ) do
				local maxTimes 	= GetActivityGuideMaxTimes( sysarg, guildCfg.id )
				local doneTimes = GetActivityGuideDoneTimes( sysarg, guildCfg.id )
				DataPack.writeShort(netPack, guildCfg.id)
				DataPack.writeShort(netPack, maxTimes)
				DataPack.writeShort(netPack, doneTimes)
				--print("--->ActivityGuideGetTimes, activityId="..guildCfg.id..", maxTimes="..maxTimes..", doneTimes="..doneTimes)
			end
		end
		DataPack.flush(netPack)
	end
end

function GetActivityGuideCount( )
	local count = 0
	for groupIdx, guideGroupCfg in ipairs( ActivityGuideCfg ) do
		count = count + #guideGroupCfg.activities
	end
	return count
end

function GetActivityGuideMaxTimes( sysarg, activityId )
	if activityId == ACTIVITY_DEFINE_STONE_TOMB then
		return GetActorDailyMaxTimes( sysarg, enDailyOpTimes_StoneTomb, 0 )
	elseif activityId == ACTIVITY_DEFINE_PERSON_BOSS then		--个人BOSS
		local maxTimes = 0
		for bossIdx, bossConfig in ipairs( PersonBossConfig ) do
			if Actor.checkActorLevel( sysarg, bossConfig.enterLevelLimit[2], bossConfig.enterLevelLimit[1] ) then
				maxTimes = maxTimes + GetActorDailyMaxTimes( sysarg, enDailyOpTimes_PersonBoss, bossIdx )
			end
		end
		return maxTimes
	elseif activityId == ACTIVITY_DEFINE_MATERIAL then			--材料副本
		local maxTimes = 0
		for fubenIdx, fubenConfig in ipairs( MaterialFubenCfg ) do
			if Actor.checkActorLevel( sysarg, fubenConfig.levelLimit[2], fubenConfig.levelLimit[1] ) then
				maxTimes = maxTimes + GetActorDailyMaxTimes( sysarg, enDailyOpTimes_MaterialFuben, fubenIdx )
			end
		end
		return maxTimes
	elseif activityId == ACTIVITY_DEFINE_ENTRUST_QUEST then				--伏魔任务
		local maxTimes = 0
		maxTimes = maxTimes + GetActorDailyMaxTimes( sysarg, enDailyOpTimes_Quest, BookQuestConfig.BookQuestId )
		--print("GetActivityGuideMaxTimes, maxTimes="..maxTimes)
		return maxTimes
	elseif activityId == ACTIVITY_DEFINE_TREASURE_MAP then				--黑市宝图
		local maxTimes = 0
		maxTimes = maxTimes + TreasureMap.buyLimit
		return maxTimes
	elseif activityId == ACTIVITY_DEFINE_SPACETRIAL then				--血域试炼
		local maxTimes = GetActorDailyMaxTimes( sysarg, enDailyOpTimes_SpaceTrial, 0 )
		--print("GetActivityGuideMaxTimes, maxTimes="..maxTimes)
		return maxTimes
	end
	return 0
end

function GetActivityGuideDoneTimes( sysarg, activityId )
	if activityId == ACTIVITY_DEFINE_STONE_TOMB then
		return GetActorDailyDoneTimes( sysarg, enDailyOpTimes_StoneTomb, 0 )
	elseif activityId == ACTIVITY_DEFINE_PERSON_BOSS then		--个人BOSS
		local doneTimes = 0
		for bossIdx, bossConfig in ipairs( PersonBossConfig ) do
			doneTimes = doneTimes + GetActorDailyDoneTimes( sysarg, enDailyOpTimes_PersonBoss, bossIdx )
		end
		return doneTimes
	elseif activityId == ACTIVITY_DEFINE_MATERIAL then			--材料副本
		local doneTimes = 0
		for fubenIdx, fubenConfig in ipairs( MaterialFubenCfg ) do
			doneTimes = doneTimes + GetActorDailyDoneTimes( sysarg, enDailyOpTimes_MaterialFuben, fubenIdx )
		end
		return doneTimes
	elseif activityId == ACTIVITY_DEFINE_ENTRUST_QUEST then				--伏魔任务
		local doneTimes = 0
		doneTimes = doneTimes + GetActorDailyDoneTimes( sysarg, enDailyOpTimes_Quest, BookQuestConfig.BookQuestId )
		--print("GetActivityGuideDoneTimes, doneTimes="..doneTimes)
		return doneTimes
	elseif activityId == ACTIVITY_DEFINE_TREASURE_MAP then				--黑市宝图
		local sVar = Actor.getStaticVar(sysarg)
		local doneTimes = sVar.days.treasureTimes or 0
		return doneTimes
	elseif activityId == ACTIVITY_DEFINE_SPACETRIAL then				--血域试炼
		local doneTimes = GetActorDailyDoneTimes( sysarg, enDailyOpTimes_SpaceTrial, 0 )
		--print("GetActivityGuideDoneTimes, doneTimes="..doneTimes)
		return doneTimes
	end
	return 0
end
